/**
 * Created by fkjslee on 2018/1/2.
 */
 var url = "http://118.24.11.68:8080";
// var url = "http://172.22.244.97:8080";

 function clickBtnReturn() {
     window.location.href= url + "/return/return.html" +
         "?account=" + GetQueryString("account");
 }

 function clickBtnCheck() {
    var request = new XMLHttpRequest();
    var data = "account=" + GetQueryString("account");
    request.open("POST", url + "/getOneDispensing?" + data);
    request.send();
    request.onreadystatechange = function () {
        if(request.readyState === 4) {
            if(request.status === 200) {
                if(request.responseText === "-1") {
                    alert("没有处方了");
                } else {
                    var text = JSON.parse(request.responseText);
                    data = "/dispensing/dispensing.html" + "?account=" + GetQueryString("account") +
                    "&patientID=" + text.patientID +
                    "&medicineName1=" + text.medicineName1 +
                    "&medicineName2=" + text.medicineName2 +
                    "&medicineName3=" + text.medicineName3 +
                    "&medicineNum1=" + text.medicineNum1 +
                    "&medicineNum2=" + text.medicineNum2 +
                    "&medicineNum3=" + text.medicineNum3 +
                    "&medicinePrice1=" + text.medicinePrice1 +
                    "&medicinePrice2=" + text.medicinePrice2 +
                    "&medicinePrice3=" + text.medicinePrice3;
                    window.location.href= url + data;
                }
            }
        }
    }
 }

 /**
  * @return {null}
  */
 function GetQueryString(name) {
     var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if (r !== null)return unescape(r[2]);
     return null;
 }